package com.equdao.car_violation_inquiry.utils;


import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.handler.inter.IExcelExportServer;
import com.equdao.car_violation_inquiry.pojo.WebPageViolationDetailDO;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * @Author: 杨忠强
 * @Date: 2018/6/25 19:13
 * @Description:
 */
public class CSVTest implements IExcelExportServer{

    private IExcelExportServer iExcelExportServer;
    @RequestMapping("export")
    public void export() throws IOException {

        //模拟从数据库获取需要导出的数据



        List<WebPageViolationDetailDO> personList = new ArrayList<>();


        WebPageViolationDetailDO violationDetailDO = new WebPageViolationDetailDO();
        violationDetailDO.setId("0");
        violationDetailDO.setCph("浙GL8S90");
        violationDetailDO.setWzsj("2016/11/15 19:21:28");
        violationDetailDO.setWzdd("[萧山]萧山－横石板路_横石板路直石板路口(违停-横石板弄直石板弄路口东口)");
        violationDetailDO.setWzxw("不按规定临时停车影响其他车辆和行人通行的");
        violationDetailDO.setWzfk("150");
        violationDetailDO.setWzjf("0");
        violationDetailDO.setCsmc("浙江金华");
        violationDetailDO.setCsdm("3307");
        violationDetailDO.setWfdm("7003");
        violationDetailDO.setClbj("3");
        violationDetailDO.setMsg("发动机号错误");
        violationDetailDO.setFdj("192001454");
        violationDetailDO.setCjh("LSVGP4553C2024708");
//        Person person2 = new Person("娜美","2");
//        Person person3 = new Person("索隆","1");
//        Person person4 = new Person("小狸猫","1");

        for (int i = 0; i < 1000000; i++) {

        personList.add(violationDetailDO);

        }
//        personList.add(person2);
//        personList.add(person3);
//        personList.add(person4);




        //导出操作s

        Workbook workbook = ExcelExportUtil.exportBigExcel(new ExportParams(), WebPageViolationDetailDO.class, personList);
        FileOutputStream fos = new FileOutputStream("E:/img/simple.xlsx");
        workbook.write(fos);
        workbook.close();
    }



    public static void main(String[] args) throws IOException {
        CSVTest csvTest = new CSVTest();
        csvTest.export();
    }

    @Override
    public List<Object> selectListForExcelExport(Object obj, int page) {
        return null;
    }
}
